use "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Data Files/Wave 2.dta"
cd "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures"

***Define Demographic Variables***

generate PID3 =.
replace PID3 = 1 if PARTYID < 4
replace PID3 = 2 if PARTYID == 4
replace PID3 = 3 if PARTYID > 4 & PARTYID < 8 

gen DEM = 0 if PID3 > 0
replace DEM = 1 if PID3 == 1
gen REP = 0 if PID3 > 0
replace REP = 1 if PID3 == 3

gen IDEO3 = .
replace IDEO3 = 1 if IDEO < 4
replace IDEO3 = 2 if IDEO == 4
replace IDEO3 = 3 if IDEO > 4 & IDEO < 8

label define LIBCONV3 0 "None" 1 "Liberal" 2 "Moderate" 3 "Conservative"
label values IDEO3 LIBCONV3 

label define PID3 1 "Democrat" 2 "Independent" 3 "Republican"
label values PID3 PID3

replace Q11 =. if Q11 == 98
replace VETERAN =. if VETERAN == 98
replace VETERAN2 =. if VETERAN2 == 98
gen VET = VETERAN * (-1)

generate MILVET =.
replace MILVET = 0 if VETERAN > 1 & VETERAN < 77
replace MILVET = 1 if VETERAN == 1
replace MILVET = 2 if VETERAN == 1 & VETERAN_RES == 1

label define MILVET 0 "Civilian" 1 "Veteran" 2 "NG/Reserve Vet"
label values MILVET MILVET

generate Post911 =.
replace Post911 = 0 if VETERAN == 1 & VETERAN4 == 1
replace Post911 = 1 if VETERAN == 1 & VETERAN4 > 1 & VETERAN4 == 2
replace Post911 = 0 if VETERAN == 1 & VETERAN4 > 1 & VETERAN4 == 3

label define Post911 0 "Served Before 9/11" 1 "Served After 9/11"
label values Post911 Post911

generate Q11T =.
replace Q11T = 0 if Q11 > 2
replace Q11T = 1 if Q11 < 3

label define Confidence 0 "Not Confident" 1 "Confident"
label values Q11T Confidence

gen WOMAN = GENDER - 1

generate FAMILY = 0 if Q39 < 77
replace FAMILY = 1 if Q39 == 1

gen SOCIAL = 0 if Q38 < 98
replace SOCIAL = 1 if Q38 == 1

replace URBAN3 =. if URBAN3 < 1

generate white = 0
replace white = 1 if RACE == 1
generate black = 0
replace black = 1 if RACE == 2
replace black = 1 if RACE == 3
generate hispanic = 0
replace hispanic = 1 if RACE == 4
generate asian = 0
replace asian = 1 if RACE == 6

gen RACE2 = RACE if RACETHNICITY < 77
replace RACE2 =. if RACETHNICITY == 3
replace RACE2 = 2 if RACETHNICITY == 5

label define RACE 1 "White" 2 "Black" 4 "Hispanic" 6 "Asian"
label values RACE2 RACE

gen EDUC3 = . if EDUC5 > 5
replace EDUC3 = 1 if EDUC5 < 3
replace EDUC3 = 2 if EDUC5 == 3
replace EDUC3 = 2 if EDUC5 == 4
replace EDUC3 = 3 if EDUC5 == 5

gen midwest = 0
replace midwest = 1 if REGION4 == 2
gen south = 0
replace south = 1 if REGION4 == 3
gen west = 0
replace west = 1 if REGION4 == 4

generate religion = 0 if RELIG < 98
replace religion = 1 if RELIG == 1
replace religion = 2 if RELIG == 2
replace religion = 3 if RELIG > 8 & RELIG < 12
replace religion = 1 if RELIG == 12

generate christian = 0
replace christian = 1 if religion == 1
generate catholic = 0
replace catholic = 1 if religion == 2
generate norelig = 0
replace norelig = 1 if religion == 3

gen married =.
replace married = 1 if MARITAL == 1
replace married = 0 if MARITAL > 1

generate unemployed = 1 if EMPLOY < 3
replace unemployed = 0 if EMPLOY > 2

generate city = 0
replace city = 1 if URBAN3 == 1
generate rural = 0
replace rural = 1 if URBAN3 == 3

gen VET2 = 0 if VETERAN < 77
replace VET2 = 1 if VETERAN2 == 1

gen d2 = 0
gen d3 = 0
gen d4 = 0
gen d5 = 0
gen d6 = 0
gen d7 = 0
gen d8 = 0

replace d2 = 1 if P_ASSIGN1 == 2
replace d3 = 1 if P_ASSIGN1 == 3
replace d4 = 1 if P_ASSIGN1 == 4
replace d5 = 1 if P_ASSIGN1 == 5
replace d6 = 1 if P_ASSIGN1 == 6
replace d7 = 1 if P_ASSIGN1 == 7
replace d8 = 1 if P_ASSIGN1 == 8
**************************

*******Define DVs********
recode Q5A Q5B Q5C Q5D Q5E Q5F Q5G Q5H (98=.)(77=.)(4=.)(3=0)(2=0.5)(1=1)
recode Q6A Q6B Q6C Q6D Q6E Q6F Q6G Q6H (98=.)(77=.)(4=.)(3=0)(2=0.5)(1=1)

gen Q21A = Q21
gen Q25AA = Q25A

recode Q21A Q25AA (98=.)(77=.)(5=0)(4=0)(3=0)(2=1)(1=1)

pca Q5A Q5B Q5C Q5D Q5E Q5F Q5G Q5H Q6A Q6B Q6C Q6D Q6E Q6F Q6G Q6H [aweight=weight2]
factor Q5A Q5B Q5C Q5D Q5E Q5F Q5G Q5H Q6A Q6B Q6C Q6D Q6E Q6F Q6G Q6H [aweight = weight2]
quietly screeplot


gen IMPORTANT = (Q5A + Q5B + Q5C + Q5D + Q5E + Q5F + Q5G + Q5H)/8 
gen USEFUL = (Q6A + Q6B + Q6C + Q6D + Q6E + Q6F + Q6G + Q6H)/8

gen REAL = (Q5A+Q5H)/2 
gen HUMAN = (Q5D+Q5F)/2
gen SECURITY = (Q5E+Q5G)/2
gen DOMESTIC = (Q5B+Q5C)/2

gen REAL2 = (Q6A+Q6H)/2 
gen HUMAN2 = (Q6D+Q6F)/2
gen SECURITY2 = (Q6E+Q6G)/2
gen DOMESTIC2 = (Q6B+Q6C)/2

recode Q13A Q13B Q13C Q13D Q13E Q13F Q13G Q13H (77=.)(98=.)


************************************
*****Figure 9.1*****
graph bar (mean) IMPORTANT if P_ASSIGN1 == 1 & Q11 < 5 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(small))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(IMPORTANCE) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle("Importance of Military Missions", size(medsmall) margin(right))

graph bar (mean) USEFUL if P_ASSIGN1 == 1 & Q11 < 5 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(small))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(USEFUL) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle("Usefulness of Military Missions", size(medsmall) margin(right))

graph combine IMPORTANCE USEFUL, graphregion(fcolor(white) lcolor(white)) name(FIG91, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG91.jpg", as(jpg) name("FIG91") quality(100) replace

*****

*****Figure 9.2*****
graph bar (mean) REAL if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Realpolitik Missions) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Realpolitik) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph bar (mean) HUMAN if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Humanitarian Missions) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Humanitarian) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph bar (mean) SECURITY if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Homeland Security) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Security) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph bar (mean) DOMESTIC if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Domestic Social Work) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Domestic) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph combine Realpolitik Humanitarian Security Domestic, graphregion(fcolor(white) lcolor(white)) name(FIG92, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG92.jpg", as(jpg) name("FIG92") quality(100) replace
*****

*****Figure 9.3*****
graph bar (mean) Q5B if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Military in Redressing Discrimination) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Race) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph bar (mean) Q5C if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(horizontal) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Disaster Relief) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Disaster) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right))

graph combine Race Disaster, graphregion(fcolor(white) lcolor(white)) name(FIG93, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG93.jpg", as(jpg) name("FIG93") quality(100) replace
*****

*****Figure 9.4*****
graph bar (mean) REAL if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Realpolitik Missions) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(RealpolitikP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph bar (mean) HUMAN if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Humanitarian Missions) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(HumanitarianP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph bar (mean) SECURITY if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Homeland Security) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(SecurityP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph bar (mean) DOMESTIC if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Domestic Social Work) ytitle(, size(vsmall)) yscale(range(0 1)) ylabel(#6) name(DomesticP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph combine RealpolitikP HumanitarianP SecurityP DomesticP, graphregion(fcolor(white) lcolor(white)) name(FIG94, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG94.jpg", as(jpg) name("FIG94") quality(100) replace
*****

*****Figure 9.5*****
graph bar (mean) Q5D if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Humanitarian Missions Abroad) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(AbroadP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph bar (mean) Q5F if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Importance of Civil War Intervention) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(CivilWarP) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph combine AbroadP CivilWarP, graphregion(fcolor(white) lcolor(white)) name(FIG95, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG95.jpg", as(jpg) name("FIG95") quality(100) replace
*****

*****Figure 9.6*****
graph bar (mean) Q6D if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Usefulness of Humanitarian Missions Abroad) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Abroad2P) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph bar (mean) Q6C if P_ASSIGN1 == 1 [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Usefulness of Disaster Relief) ytitle(, size(small)) yscale(range(0 1)) ylabel(#6) name(Disaster2P) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(medsmall)))

graph combine Abroad2P Disaster2P, graphregion(fcolor(white) lcolor(white)) name(FIG96, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG96.jpg", as(jpg) name("FIG96") quality(100) replace

*****Figure 9.7*****
graph bar (mean) Q21A [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Percent Support for Iran Strikes) ytitle(, size(medsmall)) yscale(range(0 1)) ylabel(#6) name(Iran, replace) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(vsmall)))

graph bar (mean) Q25AA [pweight = weight2], over(Q11T, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Percent Support for Insurrection Act) ytitle(, size(medsmall)) yscale(range(0 1)) ylabel(#6) name(Insurrection, replace) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(PID3, label(labsize(vsmall)))
*****


clear

use "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Data Files/Wave 1 Weighted.dta"

***Defining Variables***
generate pid3 =.
replace pid3 = 1 if partyid7 < 4
replace pid3 = 2 if partyid7 == 4
replace pid3 = 3 if partyid7 > 4

generate ideo3 =.
replace ideo3 = 1 if ideo < 4
replace ideo3 = 2 if ideo == 4
replace ideo3 = 3 if ideo > 4 & ideo < 8
replace ideo3 = 4 if ideo == 8

generate q8a = .
replace q8a = 0 if q8 < 77
replace q8a = 1 if q8 < 3

generate q82a = q8a
recode q82a (0=1)(1=0)

generate q19h2 = .
replace q19h2 = 0 if q19h < 77
replace q19h2 = -1 if q19h < 3
replace q19h2 = 1 if q19h > 3 & q19h < 77

generate q19ah2 = .
replace q19ah2 = 0 if q19ah < 77
replace q19ah2 = -1 if q19ah < 3
replace q19ah2 = 1 if q19ah > 3 & q19ah < 77


generate q33ac2 = .
replace q33ac2 = 0 if q33ac < 77
replace q33ac2 = 1 if q33ac < 3
replace q33ac2 = -1 if q33ac > 3 & q33ac < 77

generate q33c2 = .
replace q33c2 = 0 if q33c < 77
replace q33c2 = 1 if q33c < 3
replace q33c2 = -1 if q33c > 3 & q33c < 77


generate q33ad2 = .
replace q33ad2 = 0 if q33ad < 77
replace q33ad2 = 1 if q33ad < 3
replace q33ad2 = -1 if q33ad > 3 & q33ad < 77

generate q42a2 = .
replace q42a2 = 0 if q42a < 77
replace q42a2 = 1 if q42a < 3

generate q42b2 = .
replace q42b2 = 0 if q42b < 77
replace q42b2 = 1 if q42b < 3

label define BI2 0 "Don't Agree" 1 "Agree"
label values q42a2 q42b2 BI2

label define CONFIDENT 1 "A Great Deal" 2 "Quite a Lot" 3 "Some" 4 "Almost None"
label values q8 CONFIDENT
label define CONFIDENCE 1 "Confident" 0 "Not Confident"
label values q8a CONFIDENCE
label define CONFIDENCE1 0 "Conf" 1 "NotConf"
label values q82a CONFIDENCE1
label define TRI -1 "Agree" 0 "Neither" 1 "Disagr"
label values q33c2 q33ac2 q33ad2 TRI
label values q19h2 q19ah2 TRI
label define YN 1 "Yes" 2 "No" 3 "Don't Know" 77 "Don't Know'"
label values q44 q46 q47 YN
label define veteran 1 "Veteran" 2 "Civilian"
label values veteran veteran

label define PID3 1 "Democrat" 2 "Independent" 3 "Republican"
label values pid3 PID3


************************************
*****Table 9.3*****
tabout q19h2 q82a if dov_assignment_a == 1 using tab93a.txt [aweight=weight], replace cells(col freq) f(0)
tabout q19ah2 q82a if dov_assignment_a == 1 using tab93b.txt [aweight=weight], replace cells(col freq) f(0)

*****Table 9.4*****
tabout q28d q82a if dov_assignment_a == 1 & q28d < 98 using tab94a.txt [aweight=weight], replace cells(col freq) f(0)
tabout q28ad q82a if dov_assignment_a == 1 & q28ad < 98 using tab94b.txt [aweight=weight], replace cells(col freq) f(0)

*****Figure 9.7*****
graph bar (mean) q42a2 [pweight = weight], over(q8a, label(angle(vertical) labsize(vsmall))) bar(1, fcolor(gs6)) blabel(bar, color(black) format(%3.2f)) ytitle(Percent Support for Border Mission) ytitle(, size(medsmall)) yscale(range(0 1)) ylabel(#6) name(Border, replace) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) ytitle(, margin(right)) over(pid3, label(labsize(vsmall)))

graph combine Iran Insurrection Border, graphregion(fcolor(white) lcolor(white)) name(FIG97, replace) row(1)
graph combine Abroad2P Disaster2P, graphregion(fcolor(white) lcolor(white)) name(FIG96, replace)
graph export "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Figures/Chapter 9 Figures/FIG97.jpg", as(jpg) name("FIG97") quality(100) replace

*****Table 9.5*****
tabout q28b q82a if dov_assignment_a == 1 & q28b < 98 using tab95a.txt [aweight=weight], replace cells(col freq) f(0)
tabout q28ab q82a if dov_assignment_a == 1 & q28ab < 98 using tab95b.txt [aweight=weight], replace cells(col freq) f(0)

*****Table 9.6*****
tabout q28aa q82a if dov_assignment_a == 1 & q28aa < 98 using tab96a.txt [aweight=weight], replace cells(col freq) f(0)
tabout q28a q82a if dov_assignment_a == 1 & q28a < 98 using tab96b.txt [aweight=weight], replace cells(col freq) f(0)
